﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ALDIOrganizer.Properties;

namespace ALDIOrganizer
{
    /// <summary>
    /// Stores TotalHours number of hours, differentiating between On- and off productivity
    /// </summary>
    /// <remarks>
    /// Used to store the number of hours crew members have worked
    /// (either in TotalHours, or each of them individually)
    /// </remarks>
    [Serializable]
    public struct SumOfHours
    {
        public double OnProductivity;
        public double OffProductivity;
        public double GetTotal
        {
            get
            {
                return OnProductivity + OffProductivity;
            }
        }        

        public static SumOfHours operator +(SumOfHours arg1, SumOfHours arg2)
        {
            arg1.OnProductivity += arg2.OnProductivity;
            arg1.OffProductivity += arg2.OffProductivity;
            return arg1;
        }

        public override string ToString()
        {
            return ToString(String.Empty);
        }

        public string ToString(string pFormat)
        {
            var text = String.Empty;

            if (pFormat == String.Empty)
            {
                text = Resources.LABEL_TotalHours.Replace(
                    "#",
                    OnProductivity.ToString());
            }
            if (pFormat.ToLower().Trim() == "contract")
            {
                text = Resources.LABEL_TotalContractHours.Replace(
                    "#",
                    OnProductivity.ToString());
            }

            if (OffProductivity > 0)
            {
                text += Resources.LABEL_OffProdHours.Replace(
                    "#",
                    OffProductivity.ToString());
            }
            return text;
        }
    }   

}
